/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	ParameterBinderConstantBuffer.cpp
*
*	Comments	-	See ParameterBinderConstantBuffer.h
*
**************************************************************************************/
#include "../Include/ParameterBinderConstantBuffer.h"
#include "../Include/ParameterConstantBuffer.h"
#include "../Include/ConstantBuffer.h"

namespace Pulse
{
	ParameterBinderConstantBuffer::ParameterBinderConstantBuffer( void )
		: m_pBuffer( PSX_NULL )
	{

	}

	ParameterBinderConstantBuffer::ParameterBinderConstantBuffer( IParameter *pParam )
		: m_pBuffer( PSX_NULL )
	{
		SetParameter( pParam );
	}

	ParameterBinderConstantBuffer::~ParameterBinderConstantBuffer( void )
	{
		if ( m_pBuffer )
			m_pBuffer->Release();
	}

	void ParameterBinderConstantBuffer::SetData( ConstantBuffer *pBuffer )
	{
		if ( m_pBuffer )
			m_pBuffer->Release();

		m_pBuffer = pBuffer;

		if ( pBuffer )
			pBuffer->AddRef();
	}

	void ParameterBinderConstantBuffer::BindValue( void )
	{
		m_pConstantBufferParam->SetData( m_pBuffer );
	}

}